<html>

<!-- Mirrored from introcomputing.org/table-4-exercises.html by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 24 Jan 2019 10:59:38 GMT -->
<head>
<title>Table 4 Exercises</title>
<link rel=stylesheet href=style.css type="text/css">

</head>
<body>
<script type="text/javascript" src="cs101.js"></script>
<script type="text/javascript" src="cs101-table.js"></script>
<script type="text/javascript" src="cs101-simulation.js"></script>

<!-- njp
<div id=warning-output></div>
-->

<h1>Table 4 Exercises</h1>

<p>



<p>
For these exercises, write code to count names which meet certain conditions and print a line like the following to report the count.

<pre>
count: 23
</pre>

<p>The code to produce the above line looks like following, but the real work is in initializing and updating the <b>count</b> variable (or whatever variable you use).

<pre>
print("count:", count);
</pre>

<p>The starter code includes the standard <code>count = 0;</code> line to set count to zero before starting.

<!--
  For each exercise, the number of matching names is small enough that you can print and count them by hand to verify that your code is right before "submit" time.
-->

<p>
1. Write code to count and print number of names starting with the letter "O". The last line printed should look like the "count: 23" example above (note: the answer is not 23, that's just a number I made up). 

<p style='max-width:1000'>
<table class=run>
<tr><td valign=top width=550> <!-- CODE -->
<textarea id="table4-ex1" rows=11 cols=70  class=tacode spellcheck=false
onKeyPress='return handleCR(this ,event)'>
table = new SimpleTable("baby-2010.csv");
count = 0;
for (row: table) {
  // your code here
  
}</textarea>
<br><input type=button style='width:220;height:40;background-color:lightgray'
value="Run" onClick='evaluateClear("table4-ex1")'>
</td>
<td valign=top> <!-- OUTPUT -->
<div id='table4-ex1-output' style="font-family:courier;font-size:14;"></div>
</td></tr>
</table>



<p>
2. Write code to count and print number of girl names starting with "T". The last line printed should look like the "count: 23" example above.

<p style='max-width:1000'>
<table class=run>
<tr><td valign=top width=550> <!-- CODE -->
<textarea id="table4-ex2" rows=11 cols=70  class=tacode spellcheck=false
onKeyPress='return handleCR(this ,event)'>
table = new SimpleTable("baby-2010.csv");
count = 0;
for (row: table) {
  // your code here
  
}</textarea>
<br><input type=button style='width:220;height:40;background-color:lightgray'
value="Run" onClick='evaluateClear("table4-ex2")'>
</td>
<td valign=top> <!-- OUTPUT -->
<div id='table4-ex2-output' style="font-family:courier;font-size:14;"></div>
</td></tr>
</table>


<p>
3. Write code to count and print number of boy names ending with "d". The last line printed should look like the "count: 23" example above.

<p style='max-width:1000'>
<table class=run>
<tr><td valign=top width=550> <!-- CODE -->
<textarea id="table4-ex3" rows=10 cols=70  class=tacode spellcheck=false
onKeyPress='return handleCR(this ,event)'>
table = new SimpleTable("baby-2010.csv");
for (row: table) {
  // your code here
  
}</textarea>
<br><input type=button style='width:220;height:40;background-color:lightgray'
value="Run" onClick='evaluateClear("table4-ex3")'>
</td>
<td valign=top> <!-- OUTPUT -->
<div id='table4-ex3-output' style="font-family:courier;font-size:14;"></div>
</td></tr>
</table>


<p>
4. (optional) How many names ending in "m" are there with a rank &lt;= 500? Write code to count and print this number. As usual, the last line printed should look like the "count: 23" example above.

<p style='max-width:1000'>
<table class=run>
<tr><td valign=top width=550> <!-- CODE -->
<textarea id="table4-ex4" rows=10 cols=70  class=tacode spellcheck=false
onKeyPress='return handleCR(this ,event)'>
table = new SimpleTable("baby-2010.csv");
count = 0;
for (row: table) {
  // your code here
  
}</textarea>
<br><input type=button style='width:220;height:40;background-color:lightgray'
value="Run" onClick='evaluateClear("table4-ex4")'>
</td>
<td valign=top> <!-- OUTPUT -->
<div id='table4-ex4-output' style="font-family:courier;font-size:14;"></div>
</td></tr>
</table>



</body>

<!-- Mirrored from introcomputing.org/table-4-exercises.html by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 24 Jan 2019 10:59:38 GMT -->
</html>

